/* Helsinki University of Technology
 * T-106.530 Embedded Systems
 *
 * Car-project
 * HW interface
 *
 * Target: Atmel AVR ATmega32
 *
 * Author: Petri Hintukainen, 44020U
 * Date:   2012/03/16
 */

#ifndef __HW_H_
#define __HW_H_

#include <inttypes.h>

/*
 * Initialize hardware
 */

void hw_init(void);

/*
 * current time (ms)
 */

uint64_t hw_time_us(void);
uint32_t hw_time_ms(void);

/*
 * User interface
 */

int  hw_read_button(void);
void hw_set_led(int state);

void hw_lcd_byte(uint8_t c);
void hw_lcd_ctrl(uint8_t c);

/*
 * servo
 */

void hw_servo_set(uint8_t angle); // angle: 0 ... 255

/*
 * Motor interface
 */

#define HW_MOTOR_SPEED_MAX 255

int16_t hw_motor_speed(int16_t speed); // -255 ... 255
int16_t hw_current_speed(void);

/*
 * Sensors
 */

unsigned int hw_ir_state(void);


#endif /* __HW_H_ */
